Skip to main content

All Questions

Tagged with
3votes
1answer
72views

Counting bigrams in XML files in a directory tree

I've written this code in Scala that extracts bigram statistics from the Reuters dataset. It puts the statistics in a Map[String, SortedMap[String, Int]]. For ...
Sandi's user avatar
1vote
4answers
187views

Project Euler problem 92 in Scala, square digit chains

Here is a summary of the problem: "A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before... How many starting ...
Chase G.'s user avatar
1vote
1answer
664views

Take a number and sum its digits raised to the consecutive powers

I am new to Scala have to solve this problem: If you have number "xy" should equal sum of consecutive powers of its digits xy = x^1 + y^2 For example, take the number 89 and you should ...
Elsayed's user avatar
2votes
2answers
155views

Get the highest role of a user across all the organizations he is member of

I have a function that looks like this: ...
Alex A.'s user avatar
2votes
1answer
95views

Project Euler 23 in Scala (non-abundant sums)

I recently overhauled my solution to Project Euler Problem 23 (which asks for the sum of all positive integers which cannot be written as the sum of two abundant numbers) to move it from an imperative ...
Chase G.'s user avatar
5votes
1answer
264views

Scala Docx generator from CSV input, using the docx4j library and Scala Swing

I am working on an application which takes as input a CSV file containing a list of attributes and a .docx template containing variable names equal to the columns ...
Claudius's user avatar
1vote
2answers
233views

Find the most frequent character in a string

I'm trying to solve this problem https://community.topcoder.com/stat?c=problem_statement&pm=40 Given a string made up of ONLY letters and digits, determine which character is repeated the ...
stan's user avatar
  • 209
8votes
1answer
351views

Sieve of Eratosthenes performance; Scala very slow compared to Node.js

I am new to Scala so it might show. I am learning it for one of my classes and have to write a performance benchmark. I have written the Sieve of Eratosthenes in both Node.js and Scala, and my Node.js ...
John's user avatar
  • 384
6votes
2answers
1kviews

Monte-Carlo method to estimate Pi runs slower in multiple threads, than in single thread

I'm learning Scala, and I wrote a program to estimate the value of Pi. When I'm using multiple threads, it takes 5-6 times longer to calculate the same iterations. I wrote a similar program in Java, ...
Adamsan's user avatar
4votes
1answer
199views

Solving a digitwise addition equation in Scala

I've written the following codes in Scala and Java to solve cryptarithmatic problems. E.g. For SEND+SOME=MONEY, assign the digits 0 to 9 such that the equation holds true. The algorithm I've used is ...
Satyendra Kumar's user avatar
6votes
1answer
599views

Conway's Game of Life in Scala

To learn Scala, coming from Java and Python, I'm attempting to program an implementation of Conway's Game of Life. I've implemented two different approaches so far, with the first being so bad I'm ...
Himself12794's user avatar
2votes
1answer
96views

Checking whether a game board is full

I have a method in Scala that checks if a game board is full or not. To speed this method up, I return inside the nested for loop to break out of both of them and stop execution. How would I achieve ...
Martijn's user avatar
2votes
2answers
427views

Comparing equivalent Scala and C# string-manipulation code - with Scala running much slower

I am very early in my journey of learning Scala, and I was doing challenges on hackerrank.com to get used to the syntax. As I finished one (very trivial) challenge, I noticed that the run times seem ...
Ruslan's user avatar
4votes
2answers
132views

Timing Project Euler Problem 1

Is there a better way to time the functions and print the result and function name dynamically? ...
firephil's user avatar
2votes
1answer
387views

Testing Promises vs Lock performance

I'm not sure if my lock usage is correct and safe. I wanted to know what will be best approach to deal with situation when one thread have to wait for being initialized by another so I written this ...
czajah's user avatar

153050per page
close